﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Home.MobileSales.Print
{
    internal static class BuildString
    {
        internal static string CenterLine(string str, int length)
        {
            if (str.Length <= length)
            {
                StringBuilder sb = new StringBuilder();
                int begin = length/2 - str.Length/2;
                for (int i = 0; i < begin; i++)
                {
                    sb.Append(" ");
                }
                sb.Append(str);
                while (sb.Length <= length)
                {
                    sb.Append(" ");
                }
                return sb.ToString();
            }
            else
            {
                return str;
            }
        }

        internal static string FillLine(char letter, int length)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < length; i++)
            {
                sb.Append(letter);
            }
            return sb.ToString();
        }
    }
}
